"""huadijianshe_website URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.views.generic import RedirectView
from rest_framework import routers
from django.urls import re_path as url, include
from django.views import static
from huadijianshe_website import settings
from django.views.static import serve
from src.abcarta import views as abcarta_views


router = routers.DefaultRouter()
router.register(r'products', abcarta_views.ProductsViewSet, basename="products")
router.register(r'orders', abcarta_views.OrdersViewSet, basename="orders")
router.register(r'product_detail', abcarta_views.ProductDetailViewSet, basename="productDetail")
router.register(r'products_search', abcarta_views.ProductsSearchViewSet, basename="productsSearch")
router.register(r'core_product/list', abcarta_views.GetProductViewSet, basename="list_depart_product")
router.register(r'core_product/filter', abcarta_views.FilterProViewSet, basename="filter_depart_product")
router.register(r'core_product/mapping', abcarta_views.GetMappingViewSet, basename="list_name_mapping")
router.register(r'data_processor/download', abcarta_views.DataProcessesViewSet, basename="数据处理")
router.register(r'data_processor/upload', abcarta_views.DataProcessesViewSet, basename="数据处理")
router.register(r'data_processor/uploadPdf', abcarta_views.PdfProcessViewSet, basename="上传pdf")
router.register(r'partner/list', abcarta_views.PartnersManageViewSet, basename="list_partners")
router.register(r'partner/create', abcarta_views.PartnersManageViewSet, basename="create_partner")
router.register(r'partner/update', abcarta_views.PartnersManageViewSet, basename="update_partner")
router.register(r'partner/delete', abcarta_views.PartnersManageViewSet, basename="delete_partner")


router.register(r'honour/list', abcarta_views.HonourManageViewSet, basename="list_Honour")
router.register(r'honour/create', abcarta_views.HonourManageViewSet, basename="create_Honour")
router.register(r'honour/update', abcarta_views.HonourManageViewSet, basename="update_Honour")
router.register(r'honour/delete', abcarta_views.HonourManageViewSet, basename="delete_Honour")


router.register(r'news/list', abcarta_views.NewsManageViewSet, basename="list_news")
router.register(r'news', abcarta_views.NewsDetailViewSet, basename="NewsDetailViewSet")
router.register(r'news/create', abcarta_views.NewsManageViewSet, basename="create_news")
router.register(r'news/update', abcarta_views.NewsManageViewSet, basename="update_news")
router.register(r'news/delete', abcarta_views.NewsManageViewSet, basename="delete_news")


router.register(r'project', abcarta_views.ProjectManageViewSet, basename='project')

router.register(r'project_upload_img', abcarta_views.ProjectUploadImg, basename="中标项目图片")
router.register(r'image_processor/upload', abcarta_views.ProductImagesViewSet, basename="图片处理")
router.register(r'partner_img/upload', abcarta_views.PartnerImagesViewSet, basename="合作伙伴图片")
router.register(r'honour_img/upload', abcarta_views.HonourImagesViewSet, basename="荣誉图片")
router.register(r'three_news', abcarta_views.ThreeNewsView, basename='three_news')
urlpatterns = [
    path('api/news/upload/', abcarta_views.upload_news_image, name='upload_news_image'),
    path('admin/', admin.site.urls),
    url('^api/', include(router.urls)),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    path('console/', include('src.abcarta.urls')),
    path('login.html/', abcarta_views.auth_login),
    path('products/', abcarta_views.product_search),
    path('products/details/', abcarta_views.product_details),

    path('about_abcarta/', abcarta_views.about_abcarta, name='about_abcarta'),
    path('api/news/<int:pk>/details/', abcarta_views.NewsDetailWithNavigation.as_view(), name='news-detail-navigation'),
    path('honour/', abcarta_views.honour, name='honour'),
    path('about_us/', abcarta_views.about_us, name='about_us'),
    path('contact_us/', abcarta_views.contact_us, name='contact_us'),
    path('favicon.ico', RedirectView.as_view(url='/static/favicon.ico', permanent=True)),
    path('business/', abcarta_views.business, name='business'),
    path('news/', abcarta_views.news, name='news'),
    path('news/details/', abcarta_views.news_details),
    path('dynamic/', abcarta_views.dynamic, name='dynamic'),
    path('dynamic/details/', abcarta_views.dynamic_details),
    path('product_service/', abcarta_views.product_service, name='product_service'),
    path('machine_detail/', abcarta_views.machine_detail, name='machine_detail'),
    path('core_product/', abcarta_views.core_product, name='core_product'),
    path('', abcarta_views.core_product, name='home_pag'),
    path('research_cooperation/', abcarta_views.research_cooperation, name='research_cooperation'),
]

if not settings.DEBUG:
    urlpatterns += [url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT})]
urlpatterns += [url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT})]
